package jzoffer;

public class ListNode {
    int val;
    ListNode next = null;

    ListNode(int val) {
        this.val = val;
    }

    @Override
    public String toString() {
        return "ListNode{" +
                "val=" + val +
                ", next=" + next +
                '}';
    }
    public void print(){
        System.out.println(val);
        ListNode temp=next;
        while (temp!=null){
            System.out.println(temp.val);
            temp=temp.next;
        }
    }
}
